import Vue from 'vue';
import App from './App.vue';
import router from './router';
import ElementUI from 'element-ui';
import VueI18n from 'vue-i18n';
import { messages } from './components/common/i18n';
import 'element-ui/lib/theme-chalk/index.css'; // 默认主题
// import './assets/css/theme-green/index.css'; // 浅绿色主题
import './assets/css/icon.css';
import './components/common/directives';
import 'babel-polyfill';

Vue.config.productionTip = false;
Vue.prototype.$status = [{label: '禁用', value: 0}, {label: '启用', value: 1}] //公共的属性
Vue.prototype.$feeStatus = [{label: '已交', value: 2}, {label: '未交', value: 1}] //公共的属性
Vue.prototype.$result = [{label: '已化解', value: 1}, {label: '未化解', value: 2}] //公共的属性
Vue.use(VueI18n);
Vue.use(ElementUI, {
    size: 'small'
});
const i18n = new VueI18n({
    locale: 'zh',
    messages
})

// 全局路由守卫
router.beforeEach((to, from, next) => {
	const adm_token = localStorage.getItem('adm_token') // 是否登录
	// 未登录状态；
    if (!adm_token && to.path !== '/login') {
		next('/login')
    }else {
		next()
	}
});

import $https from './api/https'
Vue.prototype.$apiGet  = $https.apiGet
Vue.prototype.$apiPost = $https.apiPost
Vue.prototype.$apiPosts = $https.apiPosts
Vue.prototype.$postFile  = $https.postFile
Vue.prototype.$updateStatus = $https.updateStatus

Vue.prototype.$baseUrl = 'http://cun.lexhua.com/member/'
Vue.prototype.$imgUrl = 'http://cun.lexhua.com'

new Vue({
    router,
    i18n,
    render: h => h(App)
}).$mount('#app')
